package org.jl.demo.util;

import org.yaml.snakeyaml.Yaml;

import java.io.IOException;
import java.io.InputStream;
import java.util.Map;

public class YamlUtil {
    public static Map<String, Object> getYmlData(String fileName) {
        InputStream inputStream = YamlUtil.class.getClassLoader().getResourceAsStream(fileName + ".yml");
        // 创建Yaml对象并加载数据
        Yaml yaml = new Yaml();
        Map<String, Object> data = yaml.load(inputStream);
        try {
            if (inputStream != null) {
                inputStream.close();
            }
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
        return data;
    }
}
